package com.lyf.boot.listener;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.support.Acknowledgment;

import java.util.Objects;

/**
 * @author Luyufan
 * @date 2024/10/16
 **/
//@Component
@RequiredArgsConstructor
@Slf4j
public class KafkaMessageListener {

    /*private  KafkaListenerEndpointRegistry kafkaListenerEndpointRegistry;

    @PostConstruct
    public void inti(){
        kafkaListenerEndpointRegistry = new KafkaListenerEndpointRegistry();
    }*/

    //@KafkaListener(topics = {"topic1", "topic2"})
    public void listener(ConsumerRecord<Object, Objects> consumerRecord, Acknowledgment ack){
        log.info("收到消息：{}", consumerRecord.value());
        //手动确认
        ack.acknowledge();
    }
}
